<?

class shop {
   var $bookedItems = array( );
   
   function shop ($sessionId="1") {
      $this->sessionId = $sessionId;
	  $this->bookedItems = array ();
	  
      return $this;
   }
   
   function getBookedItems(){
	  global $db;
	  // $sql = "select * from goods";
	  //$result = $db->query($sql);
	  $this->bookedItems = unserialize($_SESSION['bookedItems']);
      return $this->bookedItems;
   }
   
   function setBookedItems($items){
      $_SESSION["bookedItems"] = serialize($items);
	  return;
   }
   
   function orderItem($itemId){
      
      if (!empty($_SESSION['bookedItems'])) {$this->bookedItems = (array) unserialize($_SESSION['bookedItems']); }     
	  
	  array_push($this->bookedItems, array('id' => $itemId, 'name'=>$itemId, 'price'=>'300'));
	  
	  $this->setBookedItems($this->bookedItems);      
   }
   
   function getCurrentSessionId () {
      return $this->sessionId;
   }
   
   function emptyShoppingCart(){
   
     $this->setBookedItems(array());
	 return;
   }
   
}

?>